/******************************************************************************
* @file    PT32X005_pwm.c
* @author  应用开发团队
* @version V1.1.0
* @date    2020/1/27
* @brief    This file provides firmware functions to manage the following
*          functionalities of the TIM peripheral:
*            + TimeBase management
*            + Output Compare management
*            + Input Capture management
*            + Interrupts, flags management
*            + Clocks management
*            + Synchronization management
*            + Specific interface management
*            + Specific remapping management
******************************************************************************
* @attention
*
*
*****************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "PT32X005_pwm.h"


/** @defgroup PWM
  * @brief PWM driver modules
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/



/**
  * @brief  Initializes the PWMx Time Base Unit peripheral according to
  *            the specified parameters in the PWM_TimeBaseInitTypeDef.
  * @param  PWMx: select the PWM peripheral.
  * @param  TimeBaseInit: pointer to a PWM_TimeBaseInitTypeDef
  *         structure that contains the configuration information for
  *         the specified PWM peripheral.
  * @retval None
  */
void PMW_TimeBaseInit(TIM1_TypeDef* PWMx, PWM_TimeBaseInitTypeDef* TimeBaseInit)
{
	u32  tmpreg = 0;
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_COUNTER_RELOAD(TimeBaseInit->CounterReload));
	assert_param(IS_PWM_CLOCKSEL(TimeBaseInit->ClockSel));
	assert_param(IS_PWM_PRESCALER(TimeBaseInit->Prescaler));
	assert_param(IS_PWM_Conter_Mode(TimeBaseInit->CounterMode));
	/* Set the counter reload value */
	PWMx->ARR = TimeBaseInit->CounterReload;
	/* Set the PWM clcok  */
	tmpreg &= ~TIM1_CR1_CLKS ;
	tmpreg |= TimeBaseInit->ClockSel;
	PWMx->CR1 = tmpreg;
	/* Set the Prescaler value */
	PWMx->PSC = TimeBaseInit->Prescaler;
	/* Select the Counter Mode */
	tmpreg = 0;
	tmpreg &= ~(TIM1_CR2_DIR | TIM1_CR2_CMS);
	tmpreg |=  (TimeBaseInit->CounterMode);
	PWMx->CR2 = tmpreg;
}

/**
  * @brief  Fills each PWM_TimeBaseInitTypeDef member with its default value.
  * @param  TimeBaseInit: pointer to a TIM_TimeBaseInitTypeDef structure
  *              which will be initialized.
  * @retval None
  */
void PWM_TimeBaseStructInit(PWM_TimeBaseInitTypeDef* TimeBaseInit)
{
	/* Set the default configuration */
	TimeBaseInit->CounterReload = 0xFFFF;
	TimeBaseInit->ClockSel = PCLK;
	TimeBaseInit->Prescaler = 0x0000;
	TimeBaseInit->CounterMode = PWM_CounterMode_Up;
}

/**
  * @brief  Initializes the PWMx channelx output
  * @param  PWMx: select the PWM peripheral.
  * @param  OutInit: pointer to a PWM_OCInitTypeDef
  *         structure that contains the configuration information for
  *         the specified PWM peripheral.
  * @retval None
  */
void PWM_OCInit(TIM1_TypeDef* PWMx, PWM_OCInitTypeDef* OutInit)
{
	u32 ch = 0;
	u32 wTmpReg = 0;
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_CHCHANNEL(OutInit->PWM_OCCh));
	assert_param(IS_PWM_OM(OutInit->PWM_OCMode));
	assert_param(IS_PWM_CHNCTL(OutInit->PWM_OutputNState));
	assert_param(IS_PWM_COMPAREVALUE(OutInit->PWM_Pulse));
	assert_param(IS_PWM_OC_POLARITY(OutInit->PWM_OCPolarity));
	assert_param(IS_PWM_OCN_POLARITY(OutInit->PWM_OCNPolarity));
	assert_param(IS_PWM_OCIDLE_STATE(OutInit->PWM_OCIdleState));
	assert_param(IS_PWM_OCNIDLE_STATE(OutInit->PWM_OCNIdleState));

	assert_param(IS_PWM_DEATHTIME(OutInit->DeathTime));
	ch = OutInit->PWM_OCCh;
	wTmpReg = PWMx->OCMR;

	/* Set the CHx Compare value and OCMR Mask*/
	if(ch == PWM_CH_1)
	{
		PWMx->OCR1 = OutInit->PWM_Pulse;
		wTmpReg &= 0xFEEEFFF0;
	}
	if(ch == PWM_CH_2)
	{
		PWMx->OCR2 = OutInit->PWM_Pulse;
		wTmpReg &= 0xFDDDFF0F;
	}
	if(ch == PWM_CH_3)
	{
		PWMx->OCR3 = OutInit->PWM_Pulse;
		wTmpReg &= 0xFBBBF0FF;
	}
	if(ch == PWM_CH_4)
	{
		PWMx->OCR4 = OutInit->PWM_Pulse;
		wTmpReg &= 0xF7770FFF;
	}

	wTmpReg |=  (((OutInit->PWM_OCMode) << ch * 4) | \
				((OutInit->PWM_OCPolarity) << ch * 4) | \
				((OutInit->PWM_OCNPolarity) << ch * 4) | \
				((OutInit->PWM_OutputNState) << ch) | \
				((OutInit->PWM_OCIdleState) << ch) | \
				((OutInit->PWM_OCNIdleState) << ch));
	PWMx->OCMR = wTmpReg;
	/* Set the Death time */
	PWMx->DT = OutInit->DeathTime;
}

/**
  * @brief  Fills each PWM_OCInitStruct member with its default value.
  * @param  PWM_OCInitStruct : pointer to a PWM_OCInitTypeDef structure which will
  *         be initialized.
  * @retval None
  */
void PWM_OCStructInit(PWM_OCInitTypeDef* PWM_OCInitStruct)
{
	/* Set the default configuration */
	PWM_OCInitStruct->PWM_OCCh=PWM_CH_1;
	PWM_OCInitStruct->PWM_OCMode=PWM_OCMode_Inactive;
	PWM_OCInitStruct->PWM_OutputNState = PWM_OutputNState_Disable;
	PWM_OCInitStruct->PWM_Pulse = 0x0000;
	PWM_OCInitStruct->PWM_OCPolarity = PWM_OCPolarity_High;
	PWM_OCInitStruct->PWM_OCNPolarity = PWM_OCNPolarity_High;
	PWM_OCInitStruct->PWM_OCIdleState = PWM_OCIdleState_Low;
	PWM_OCInitStruct->PWM_OCNIdleState = PWM_OCNIdleState_Low;
	PWM_OCInitStruct->DeathTime = 0x00;
}

/**
  * @brief  Initializes the PWMx input Capture
  * @param  PWMx: select the PWM peripheral.
  * @param  CapInit: pointer to a PWM_ICInitTypeDef
  *         structure that contains the configuration information for
  *         the specified PWM peripheral.
  * @retval None
  */
void PWM_ICInit(TIM1_TypeDef* PWMx, PWM_ICInitTypeDef* CapInit)
{
	u32 ch = 0;
	u32 wTmpReg = 0;
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_CHCHANNEL(CapInit->PWM_ICCh));
	assert_param(IS_PWM_RC_SEL(CapInit->PWM_ICRstCount));
	assert_param(IS_PWM_POLARITY_SEL(CapInit->PWM_ICPolarity));

	ch = CapInit->PWM_ICCh;
	PWMx->OCMR &= ~(0x03 << ch * 4);	//禁止CHx 输出模式
	/* Set the CCR Reg */
	wTmpReg = PWMx->CAPR;
	wTmpReg &= ~(0x0F << ch * 4);
	wTmpReg |=  (((CapInit->PWM_ICRstCount) << ch * 4)|((CapInit->PWM_ICPolarity) << ch * 4));
	PWMx->CAPR = wTmpReg;
}

/**
  * @brief  Fills each PWM_ICInitStruct member with its default value.
  * @param  PWM_ICInitStruct : pointer to a PWM_ICInitTypeDef structure which will
  *         be initialized.
  * @retval None
  */
void PWM_ICStructInit(PWM_ICInitTypeDef* PWM_ICInitStruct)
{
	/* Set the default configuration */
	PWM_ICInitStruct->PWM_ICCh = PWM_CH_1;
	PWM_ICInitStruct->PWM_ICPolarity = PWM_ICPolarity_Rising;
	PWM_ICInitStruct->PWM_ICRstCount = PWM_ICRstCount_Disable;
}

/**
  * @brief  config the PWMx Break
  * @param  PWMx: select the PWM peripheral.
  * @param  PWM_BKIInitStruct: pointer to a TIM_BKIInitTypeDef structure that
  *               contains the Break configuration information for the specified PWM peripheral.
  * @retval None
  */
void PWM_BKIConfig(TIM1_TypeDef* PWMx,TIM_BKIInitTypeDef* PWM_BKIInitStruct)
{
	u32 tmpreg = 0;
	/* Check the parameters */
	assert_param(IS_PWM_BKI_SET(PWM_BKIInitStruct->PWM_Break));
	assert_param(IS_PWM_BKIPol_SET(PWM_BKIInitStruct->PWM_BreakPolarity));
	assert_param(IS_PWM_BKISource_SEL(PWM_BKIInitStruct->PWM_BreakSource));
	assert_param(IS_PWM_BKIControl_SET(PWM_BKIInitStruct->PWM_BreakControl));
	/* Config the BKI  */
	tmpreg = PWMx->OCMR;
	tmpreg &= ~(	TIM1_OCMR_BKE|TIM1_OCMR_BKP);
	tmpreg |= ( PWM_BKIInitStruct->PWM_Break | PWM_BKIInitStruct->PWM_BreakPolarity);
	PWMx->OCMR=tmpreg;

	tmpreg = PWMx->CR1;
	tmpreg &= ~(	TIM1_CR1_BKIS|TIM1_CR1_BKIC);
	tmpreg |= ( PWM_BKIInitStruct->PWM_BreakSource | PWM_BKIInitStruct->PWM_BreakControl);
	PWMx->CR1=tmpreg;
}

/**
  * @brief  Fills each PWM_BKIInitStruct member with its default value.
  * @param  PWM_BKIInitStruct : pointer to a TIM_BKIInitTypeDef structure which will
  *         be initialized.
  * @retval None
  */
void PWM_BKIStructInit(TIM_BKIInitTypeDef* PWM_BKIInitStruct)
{
	/* Set the default configuration */
	PWM_BKIInitStruct->PWM_Break = TIM1_Break_Enable;
	PWM_BKIInitStruct->PWM_BreakPolarity = TIM1_BreakPolarity_High;
	PWM_BKIInitStruct->PWM_BreakSource = TIM1_CR1_BKIS_TIMx_BKIN;
	PWM_BKIInitStruct->PWM_BreakControl = TIM1_Break_Idle;
}

/**
  * @brief  Configures the PWMx Interrupt Reload value.
  * @param  PWMx: select the PWM peripheral.
  * @param  ITReload: specifies the Interrupt Reload value.
  * @retval None
  */
void PWM_ITRepeatConfig(TIM1_TypeDef* PWMx, u8 ITReload)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_REPEATTIME(ITReload) );
	/* Set the PWM INT_RepeatTimes */
	PWMx->ITARR = ITReload;
}

/**
  * @brief  Configures the PWMx Prescaler.
  * @param  PWMx: select the PWM peripheral.
  * @param  Prescaler: specifies the Prescaler Register value (0~255)
  * @retval None
  */
void PWM_PrescalerConfig(TIM1_TypeDef* PWMx, u16 Prescaler)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_PRESCALER(Prescaler));
	/* Set the Prescaler value */
	PWMx->PSC = Prescaler;
}


/**
  * @brief  Configures the PWMx Reload value.
  * @param  PWMx: select the PWM peripheral.
  * @param  Reload: specifies the Counter reload value (0~65535)
  * @retval None
  */
void PWM_SetAutoreload(TIM1_TypeDef* PWMx, u16 Reload)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_COUNTER_RELOAD(Reload));
	/* Set the counter reload value */
	PWMx->ARR = Reload;
}

/**
  * @brief  Configures the PWMx Current Value.
  * @param  PWMx: select the PWM peripheral.
  * @param  Counter: specifies the Counter register new value.
  * @retval None
  */
void PWM_SetCounter(TIM1_TypeDef* PWMx, u16 Counter)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_COUNTER_VALUE(Counter));
	/* Set the Counter Register value */
	PWMx->CNT = Counter;
}

/**
  * @brief  Gets the PWMx Interrupt Counter value.
  * @param  PWMx: select the PWM peripheral.
  * @retval Counter Register value.
  */
u16 PWM_GetCounter(TIM1_TypeDef* PWMx)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	/* Get the Counter Register value */
	return  PWMx->CNT;
}

/**
  * @brief  Gets the PWMx Counter value.
  * @param  PWMx: select the PWM peripheral.
  * @retval Interrupt Counter value.
  */
u8 PWM_GetITCounter(TIM1_TypeDef* PWMx)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	/* Get the Counter Register value */
	return  PWMx->ITCNT;
}


/**
  * @brief  Gets the PWMx Prescaler value.
  * @param  PWMx: select the PWM peripheral.
  * @retval Prescaler Register value.
  */
u16 PWM_GetPrescaler(TIM1_TypeDef* PWMx)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	/* Get the Prescaler Register value */
	return  PWMx->PSC;
}

/**
  * @brief  Specifies the PWMx Counter Mode to be used.
  * @param  PWMx: select the PWM peripheral.
  * @param  CounterMode: specifies the Counter Mode to be used
  *            This parameter can be one of the following values:
  *            @arg PWM_CounterMode_Up: PWM Up Counting Mode
  *            @arg PWM_CounterMode_Down: PWM Down Counting Mode
  *            @arg PWM_CounterMode_CenterAligned: PWM Center Aligned Mode
  * @retval None
  */
void PWM_CounterModeConfig(TIM1_TypeDef* PWMx, u32 CounterMode)
{
	u32 tmpreg = 0;
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_Conter_Mode(CounterMode));
	/* Select the Counter Mode */
	tmpreg = PWMx->CR2;
	tmpreg &= ~(TIM1_CR2_DIR | TIM1_CR2_CMS);
	tmpreg |=  CounterMode;
	PWMx->CR2 = tmpreg;
}

/**
  * @brief  Configures the PWMx event to be generate by software.
  * @param  PWMx: select the PWM peripheral.
  * @param  TIM_EventSource: specifies the event source.
  *   This parameter can be one or more of the following values:
  *     @arg PWM_EventSource_Update: Timer update Event source
  *     @arg PWM_EventSource_Break: Timer Break event source
  * @retval None
  */
void PWM_GenerateEvent(TIM1_TypeDef* PWMx, u32 PWM_EventSource)
{
  /* Check the parameters */
  assert_param(IS_PWM_ALL_PERIPH(PWMx));

  /* Set the event sources */
  assert_param(IS_PWM_EVENT_SOURCE(PWM_EventSource));
  if(PWM_EventSource==PWM_EventSource_Update) 	PWMx->CR1 |= PWM_EventSource_Update;
  else											PWMx->OCMR|= PWM_EventSource_Break;
}

/**
  * @brief  Enable or Disable PWMx
  * @param  PWMx: select the PWM peripheral.
  * @param  NewState: This parameter can be ENABLE or DISABLE.
  * @retval None
  */
void PWM_Cmd(TIM1_TypeDef* PWMx, FunctionalState NewState)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_FUNCTIONAL_STATE(NewState));
	if (NewState == ENABLE)
	{
		/* Set the update bit */
		PWMx->CR1 |= TIM1_CR1_CEN;
	}
	else
	{
		/* Reset the update bit */
		PWMx->CR1 &= (~TIM1_CR1_CEN);
	}
}


/**
  * @brief  Enables or disables the specified PWM interrupts.
  * @param  PWMx: select the PWM peripheral.
  * @param  PWM_INT: Specify the PWM interrupts sources to be enabled or disabled.
  *          This parameter can be one of the following values:
  *        @arg PWM_IT_ARI
  *        @arg PWM_IT_OC1
  *        @arg PWM_IT_OC2
  *        @arg PWM_IT_OC3
  *        @arg PWM_IT_OC4
  *        @arg PWM_IT_IC1
  *        @arg PWM_IT_IC2
  *        @arg PWM_IT_IC3
  *        @arg PWM_IT_IC4
  *        @arg PWM_IT_BK
  * @param  NewState: This parameter can be ENABLE or DISABLE.
  * @retval None
  */
void PWM_ITConfig(TIM1_TypeDef* PWMx, u32 PWM_INT, FunctionalState NewState)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_IT_GET(PWM_INT));
	assert_param(IS_FUNCTIONAL_STATE(NewState));
	if(PWM_INT == TIM1_OCMR_BKI)
	{
		if (NewState != DISABLE)
		{
			/* Enable the interrupt sources */
			PWMx->OCMR |= PWM_INT;
		}
		else
		{
			/* Disable the interrupt sources */
			PWMx->OCMR &= ~PWM_INT;
		}
	}
	else if((PWM_INT == PWM_IT_ARI) | (PWM_INT == PWM_IT_OC1) | (PWM_INT == PWM_IT_OC2) | (PWM_INT == PWM_IT_OC3) | (PWM_INT == PWM_IT_OC4))
	{
		if (NewState != DISABLE)
		{
			/* Enable the interrupt sources */
			PWMx->CR2 |= PWM_INT;
		}
		else
		{
			/* Disable the interrupt sources */
			PWMx->CR2 &= ~PWM_INT;
		}
	}
	else
	{
		if(PWM_INT == PWM_IT_IC1)
		{
			if (NewState != DISABLE)
			{
				/* Enable the interrupt sources */
				PWMx->CAPR |= TIM1_CAPR_IC1I;
			}
			else
			{
				/* Disable the interrupt sources */
				PWMx->CAPR &= ~TIM1_CAPR_IC1I;
			}
		}
		else
		{
			if (NewState != DISABLE)
			{
				/* Enable the interrupt sources */
				PWMx->CAPR |= PWM_INT;
			}
			else
			{
				/* Disable the interrupt sources */
				PWMx->CAPR &= ~PWM_INT;
			}
		}
	}

}


/**
  * @brief  Checks whether the specified PWM flag is set or not.
  * @param  PWMx: select the PWM peripheral.
  * @param  PWM_FLAG: Specify the flag to be checked.
  *         This parameter can be one of the following values:
  *         @arg TIM1_SR_ARF
  *         @arg TIM1_SR_OC1F
  *         @arg TIM1_SR_OC2F
  *         @arg TIM1_SR_OC3F
  *         @arg TIM1_SR_OC4F
  *         @arg TIM1_SR_IC1F
  *         @arg TIM1_SR_IC1R
  *         @arg TIM1_SR_IC2F
  *         @arg TIM1_SR_IC2R
  *         @arg TIM1_SR_IC3F
  *         @arg TIM1_SR_IC3R
  *         @arg TIM1_SR_IC4F
  *         @arg TIM1_SR_IC4R
  *         @arg TIM1_SR_BIF
  * @return FlagStatus of PWM_FLAG (SET or RESET).
  */
FlagStatus PWM_GetFlagStatus(TIM1_TypeDef* PWMx, u32 PWM_FLAG)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_FLAG_GET(PWM_FLAG));
	if ((PWMx->SR & PWM_FLAG) != 0)
	{
		return SET;
	}
	else
	{
		return RESET;
	}
}

/**
  * @brief  Clears the PWM's pending flags.
  * @param  PWMx: select the PWM peripheral.
  * @param  PWM_FLAG: Specify the flag to be cleared.
  *         This parameter can be one of the following values:
  *         @arg TIM1_SR_ARF
  *         @arg TIM1_SR_OC1F
  *         @arg TIM1_SR_OC2F
  *         @arg TIM1_SR_OC3F
  *         @arg TIM1_SR_OC4F
  *         @arg TIM1_SR_IC1F
  *         @arg TIM1_SR_IC1R
  *         @arg TIM1_SR_IC2F
  *         @arg TIM1_SR_IC2R
  *         @arg TIM1_SR_IC3F
  *         @arg TIM1_SR_IC3R
  *         @arg TIM1_SR_IC4F
  *         @arg TIM1_SR_IC4R
  *         @arg TIM1_SR_BIF
  * @retval None
  */
void PWM_ClearFlag(TIM1_TypeDef* PWMx, u32 PWM_FLAG)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_FLAG_SET(PWM_FLAG));
	/* Clear the flags */
	PWMx->SR = PWM_FLAG;
}


/**
  * @brief  Gets the PWMx CHx Capture Counter value.
  * @param  PWMx: select the PWM peripheral.
  * @param  CHx:  Specify the Channel to be selected
  *         This parameter can be one of the following values:
  *         @arg PWM_CH_1
  *         @arg PWM_CH_2
  *         @arg PWM_CH_3
  *         @arg PWM_CH_4
  * @retval Counter Register value.
  */
u16 PWM_GetCapture(TIM1_TypeDef* PWMx, u8 CHx)
{
	u16 capture_cnt = 0;
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_CHCHANNEL(CHx));
	/* Get the Capture Counter Register value */
	if(CHx == PWM_CH_1)	capture_cnt = PWMx->ICR1 ;
	if(CHx == PWM_CH_2)	capture_cnt = PWMx->ICR2 ;
	if(CHx == PWM_CH_3)	capture_cnt = PWMx->ICR3 ;
	if(CHx == PWM_CH_4)	capture_cnt = PWMx->ICR4 ;
	return  capture_cnt;
}


/**
  * @brief  Set the PWMx CHx Compare Value
  * @param  PWMx: select the PWM peripheral.
  * @param  CHx:  Specify the Channel to be selected
  *         This parameter can be one of the following values:
  *         @arg PWM_CH_1        :
  *         @arg PWM_CH_2        :
  *         @arg PWM_CH_3        :
  *         @arg PWM_CH_4        :
  * @param  Cmp: Specify the CHx Output Compare Value value (0~0xFFFF)
  * @retval None
  */
void PWM_SetCompare(TIM1_TypeDef* PWMx, u8 CHx, u16 Cmp)
{
	/* Check the parameters */
	assert_param(IS_PWM_ALL_PERIPH(PWMx));
	assert_param(IS_PWM_CHCHANNEL(CHx));
	assert_param(IS_PWM_COMPAREVALUE(Cmp));
	/* Set PWM CH Output Compare Value*/
	if(CHx == PWM_CH_1)	PWMx->OCR1 = Cmp;
	if(CHx == PWM_CH_2)	PWMx->OCR2 = Cmp;
	if(CHx == PWM_CH_3)	PWMx->OCR3 = Cmp;
	if(CHx == PWM_CH_4)	PWMx->OCR4 = Cmp;
}

/**
  * @}
  */

